package cn.anjubao.cp.api.controller;

import cn.anjubao.cp.api.dto.*;
import cn.anjubao.cp.api.service.ParkingRecordService;
import cn.anjubao.cp.common.base.BaseResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/parking")
public class ParkingRecordController {
    @Autowired
    private ParkingRecordService  parkingRecordService;

    /**
     * 获取停车订单列表
     * @param reqForm
     * @return
     */
    @PostMapping("/order/getOrderList")
    public BaseResponse<List<OrderListResDto>> getOrderList(@Validated  @RequestBody OrderListReqForm reqForm){
        return BaseResponse.success(parkingRecordService.getOrderList(reqForm),
                parkingRecordService.getOrderListTotal(reqForm)
        );
    }

    /**
     * 获取停车订单详情
     * @param parkingRecordId
     * @return
     */
    @GetMapping("/order/{parkingRecordId}/getOrderDetails")
    public BaseResponse<OrderDetailsResDto> getOrderDetails(@PathVariable String parkingRecordId){
        return BaseResponse.success(parkingRecordService.getOrderDetails(parkingRecordId));

    }

    /**
     * 获取电子哨兵列表
     * @param reqForm
     * @return
     */
    @PostMapping("/monitor/getMonitorList")
    public BaseResponse<List<MonitorListResDto>> getMonitorList(@Validated @RequestBody MonitorListReqForm reqForm){
        return BaseResponse.success(parkingRecordService.getMonitorList(reqForm),
                parkingRecordService.getMonitorListTotal(reqForm));
    }

    /**
     * 获取电子哨兵详情
     * @param parkingRecordId
     * @return
     */
    @GetMapping("/monitor/{parkingRecordId}/getMonitorDetails")
    public BaseResponse<MonitorDetailsResDto> getMonitorDetails(@PathVariable String parkingRecordId){
        return BaseResponse.success(parkingRecordService.getMonitorDetails(parkingRecordId));
    }

    /**
     * 获取电子哨兵报警记录
     * @param alertRecordId
     * @return
     */
    @GetMapping("/monitor/{alertRecordId}/getAlertRecord")
    public BaseResponse<AlertRecordResForm> getAlertRecord(@PathVariable String alertRecordId){
        return BaseResponse.success(parkingRecordService.getAlertRecord(alertRecordId));
    }


}
